Skip to content

🚀 Implement dynamic status messages from JSON file#2192

Merged
mkmccarty merged 1 commit intomainfrom
mm-branch-3
Feb 13, 2026
Merged

🚀 Implement dynamic status messages from JSON file#2192
mkmccarty merged 1 commit intomainfrom
mm-branch-3

Conversation

@mkmccarty
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 13, 2026 16:57
@mkmccarty mkmccarty merged commit 48f2184 into main Feb 13, 2026
7 checks passed
@mkmccarty mkmccarty deleted the mm-branch-3 branch February 13, 2026 16:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the bot's status messages from hardcoded strings to a dynamic system loaded from a JSON file. The change enables easier maintenance and updates of status messages without code changes, following the same pattern used for token complaints in the codebase.

Changes:

  • Added new status_messages.go file with thread-safe loading and retrieval of status messages from JSON
  • Integrated status messages into the data download/reload system in tasks.go
  • Removed 37 hardcoded status message strings from main.go and replaced with dynamic loading
  • Added file watching for the status messages JSON file to enable hot-reloading

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/ei/status_messages.go New file implementing thread-safe loading and random selection of status messages from JSON
src/tasks/tasks.go Added constants and integration for downloading/loading status messages alongside other data files
main.go Removed hardcoded status message array, added dynamic loading at startup and file watching for hot-reload

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +25 to +38
log.Printf("Failed to open status messages file: %v", err)
return
}
defer func() {
if err := file.Close(); err != nil {
log.Printf("Failed to close: %v", err)
}
}()

var messagesLoaded StatusMessagesFile
decoder := json.NewDecoder(file)
if err := decoder.Decode(&messagesLoaded); err != nil {
log.Printf("Failed to decode status messages: %v", err)
return
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling in LoadStatusMessages differs from the similar LoadTokenComplaints function in the same package (src/ei/token_complaints.go, line 28). LoadTokenComplaints uses log.Fatal when the file cannot be opened, which ensures the application doesn't continue with missing data during startup. LoadStatusMessages logs the error and returns, which could result in an empty StatusMessages slice.

Since both functions are called during initialization (main.go line 142 and tasks.go line 366), consider using log.Fatal for consistency, or document why the different behavior is intentional. If status messages are optional, this should be clearly indicated.

Suggested change
log.Printf("Failed to open status messages file: %v", err)
return
}
defer func() {
if err := file.Close(); err != nil {
log.Printf("Failed to close: %v", err)
}
}()
var messagesLoaded StatusMessagesFile
decoder := json.NewDecoder(file)
if err := decoder.Decode(&messagesLoaded); err != nil {
log.Printf("Failed to decode status messages: %v", err)
return
log.Fatalf("Failed to open status messages file %q: %v", filename, err)
}
defer func() {
if err := file.Close(); err != nil {
log.Printf("Failed to close status messages file %q: %v", filename, err)
}
}()
var messagesLoaded StatusMessagesFile
decoder := json.NewDecoder(file)
if err := decoder.Decode(&messagesLoaded); err != nil {
log.Fatalf("Failed to decode status messages from file %q: %v", filename, err)

Copilot uses AI. Check for mistakes.
"encoding/json"
"fmt"
"log"
"math/rand"
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import uses math/rand (v1) while the rest of the codebase has migrated to math/rand/v2. This is inconsistent with the pattern used in src/tasks/tasks.go (line 7), src/boost/boost.go (line 10), src/boost/boost_admin.go (line 9), src/boost/contract.go (line 7), and src/boost/roles.go (line 7), which all use math/rand/v2.

Using the v2 API is recommended for Go 1.22+ as it provides better random number generation and doesn't require manual seeding. Change the import to use math/rand/v2 for consistency with the rest of the codebase.

Suggested change
"math/rand"
"math/rand/v2"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant